import os
import re
from lxml import etree
import requests

headers = {
    "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
    "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
    "cache-control": "no-cache",
    "pragma": "no-cache",
    "priority": "u=0, i",
    "sec-ch-ua": "\"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", \"Microsoft Edge\";v=\"138\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "document",
    "sec-fetch-mode": "navigate",
    "sec-fetch-site": "same-origin",
    "sec-fetch-user": "?1",
    "upgrade-insecure-requests": "1",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0"
}
cookies = {
  "zcid": "AAAAABdZr-RuUnbp7nqHjzp5-hTUl6tYJHn_OnqSRGWXhuADopnzwd61fsgoX-Nl9-epo8PVC8ztpp2LpviAXG0i3silc4olybm7ssULmD4d",
  "Zalando-Client-Id": "75606bfc-8bf6-4c4b-b8c7-a73caa770af9",
  "language-preference": "en",
  "_gcl_au": "1.1.1371882672.1753314944",
  "_ga": "GA1.1.1123163582.1753314912",
  "FPID": "FPID2.3.ekWpBNA7CioWPTbqawNLsW%2FKI5ejos1IxbRaOvVypjc%3D.1753314912",
  "_fbp": "fb.2.1753314946411.298647545202713527",
  "FPAU": "1.1.1371882672.1753314944",
  "ncx": "m",
  "bm_ss": "ab8e18ef4e",
  "bm_so": "B2A47DA7F90A6320782F07BACE287574C55F4F294407E63866EB138C9CE135D9~YAAQulozuORF162YAQAAucluywTai9bOaKXFkrnVcRAVpMMkCr+XhzXB5rPncM/I9sFSO+8Wjl+hTDkKcRcE2g7VJD2HKWagFXrTcqdqYiDUrdqYnkjwN8J+FgbEM5CTWVMqbYCk+GMqZfuMI3IJ1O5lJkEUXqdpugQLAn/pSPQRhKx6slhBbNnCmzmtDVx8FAp7xuI3YzGzQCR6NKWofYaBeZ1N110evHq8k5qoMLj6qLUA9qrBwQ7PifesL0DBdrAH/4WGCxumfdxqqmSOc4O9D8cI6GQUuoVW6Xq+Y1aRY27ZRkh/R4OERuxGoBK2sUi2UHS4kRVYdre4S3auOhZ5R0HTuPdZnhx8QzRIq61V8H1xXaJzwjhVB8OUYQBl5SqW/i8JgA57WIV3ICb5WxHDFqoFE3rWREv6I58gtn9aOdVKqZsjV4YBWdacMgZ/ksBWbwWdhVxnBhbDesAIybM=",
  "bm_lso": "B2A47DA7F90A6320782F07BACE287574C55F4F294407E63866EB138C9CE135D9~YAAQulozuORF162YAQAAucluywTai9bOaKXFkrnVcRAVpMMkCr+XhzXB5rPncM/I9sFSO+8Wjl+hTDkKcRcE2g7VJD2HKWagFXrTcqdqYiDUrdqYnkjwN8J+FgbEM5CTWVMqbYCk+GMqZfuMI3IJ1O5lJkEUXqdpugQLAn/pSPQRhKx6slhBbNnCmzmtDVx8FAp7xuI3YzGzQCR6NKWofYaBeZ1N110evHq8k5qoMLj6qLUA9qrBwQ7PifesL0DBdrAH/4WGCxumfdxqqmSOc4O9D8cI6GQUuoVW6Xq+Y1aRY27ZRkh/R4OERuxGoBK2sUi2UHS4kRVYdre4S3auOhZ5R0HTuPdZnhx8QzRIq61V8H1xXaJzwjhVB8OUYQBl5SqW/i8JgA57WIV3ICb5WxHDFqoFE3rWREv6I58gtn9aOdVKqZsjV4YBWdacMgZ/ksBWbwWdhVxnBhbDesAIybM=^1755759696633",
  "frsx": "AAAAAMhsjmrex8T5rbQhenCTkp1k11RtfAvH5RcRz8DQCO-kNYdrGD6SLcS8koBlLr50bmx8KpAB91qNRNa2Js3VK72HEX0dTRFhF27g5A6W4GUU3ryQBY_Ziw8uKuHYXPTDIsK-x8FvKwHunP0RYIw=",
  "mpulseinject": "false",
  "bm_mi": "F9A8C68040C9E271E55C75F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JWJTABc6kUV5i3+Ok2y5wnyZ6w3rmi5CEV30=~4535364~3753010",
  "FPLC": "2bRsuL%2BHwVnsTdn9hIvXfWB2sfqgmxpScq7J5vYSiuWjpDjEcHzTwP%2Bj%2BUlQbR%2BMm9ehWUBdQXht64Ge4x1CWmcG6PTsyVG9AFMHy8tkBbU4GeGA0kqPqsgOLkacyw%3D%3D",
  "_abck": "D807D84072F9767EA93C7AA28E1926C1~-1~YAAQulozuHFJ162YAQAA8Qdvyw4sTb86SRQK8T0AwFbGT34eVnXTftD9KWe/8QsedkzJXRwGHpO9cZQLxM6ROtgfNZJtnAXsxFnZWRSCZUMm/JBP2xW6psDdnsvqxqi7UB0UQ3ZRcc1U8/VPrL3Uq9lduOdHi8yE8a0jWhFrkxWlogXOZyPLhBv6ybWcU2FOn3wFjx2Bi0RuSgR89Eq2BrrrM54yBhqsr5D59s38ss6CT5su1rS0dEE2y/jzTKwTZK4dmIrnceySmh8Rc4TyqWxWL/iXsLeZ6nQO1NvCkIn8oJzbHHbtC1J7EcFBK76D1CvA9xoSWFwgKPMM5UtDSpC3fCOE/+5sVXaqmJz69kGSedba6ey0Cpl6J7fcKIAiHg1aTWoec2/QTigR/QLrTDXItjdq+zeubjqU4c5e2VqdZL5u9rLjShEYjqW6FpGIwQffn7Mj6pnJy1EP28OskVtoheBD/+P1r1Y12w5VOd0oAik234exVdtfOQgp9lgJPnDBvGe88gGhwkbsX1BOHh6+iMCTL1vBYi9muiSWZJ8QLyzjB73DgvE8ID9WYRcXU2h2lIFl1hu7dWVIlzlnFy1hQKcRYkJ4kvAZid5gtBJBza8oyP6uMilr7JxJCv0Cl9x6GChN4VhlzykT94k6v8vKF7Lg5JJYlaY=~-1~-1~-1",
  "_ga_MDW1S9PQPW": "GS2.1.s1755759707$o12$g0$t1755759710$j57$l0$h760933573"
}
def get(a):
    url = "https://www.zalando.co.uk/get-the-look-men/"
    params = {
        "style": "style_urban",
        "p":a


    }
    response = requests.get(url, headers=headers, cookies=cookies, params=params)#获取API接口返回的响应数据
    m = []
    pattern = r"ern:outfit::[A-Za-z0-9_-]+"#正则条件
    outfit_ids = re.findall(pattern, response.text)#使用正则把商品的ID全部提取出来
    unique_ids = list(set(outfit_ids))#商品ID去重
    for id in unique_ids:#循环商品ID
        m.append(id)#把商品ID放入一个列表并且返回m
    return m

def get_data(url):
    import requests

    headers = {
        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
        "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
        "cache-control": "no-cache",
        "pragma": "no-cache",
        "priority": "u=0, i",
        "referer": "https://www.zalando.co.uk/get-the-look-men/?style=style_urban",
        "sec-ch-ua": "\"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", \"Microsoft Edge\";v=\"138\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Windows\"",
        "sec-fetch-dest": "document",
        "sec-fetch-mode": "navigate",
        "sec-fetch-site": "same-origin",
        "sec-fetch-user": "?1",
        "upgrade-insecure-requests": "1",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0"
    }

    response = requests.get(url, headers=headers, cookies=cookies)

    return response.text
def create_folder(folder_path):
    """创建单个文件夹，不支持递归创建"""
    try:
        os.makedirs(folder_path, exist_ok=True)
        print(f"成功创建文件夹: {folder_path}")
        return True
    except FileExistsError:
        print(f"文件夹已存在: {folder_path}")
        return False
def downloadImages(path, img):
    with open(path+'.jpg', "wb") as l:
        l.write(requests.get( img).content)


def downloadVideos(path, img):
    with open(path+'.mp4', "wb") as l:
        l.write(requests.get( img).content)

def downloadTexts(path,context):
    with open(path+'.txt', "wb") as l:
        for strs in context:
            l.write(strs.encode('utf-8'))


def downtextTest(path,str):
    print(path)
    downloadTexts(path,str)



def checkStr1(str_source,str_check):#str_source：源字符串；str_check：要检查字符
    splits = str_source.split(str_check)#返回拆分数组
    return len(splits)-1#返回拆分次数-1



if __name__ == '__main__':
    cookie = {
      "zcid": "AAAAABdZr-RuUnbp7nqHjzp5-hTUl6tYJHn_OnqSRGWXhuADopnzwd61fsgoX-Nl9-epo8PVC8ztpp2LpviAXG0i3silc4olybm7ssULmD4d",
      "Zalando-Client-Id": "75606bfc-8bf6-4c4b-b8c7-a73caa770af9",
      "language-preference": "en",
      "_gcl_au": "1.1.1371882672.1753314944",
      "_ga": "GA1.1.1123163582.1753314912",
      "FPID": "FPID2.3.ekWpBNA7CioWPTbqawNLsW%2FKI5ejos1IxbRaOvVypjc%3D.1753314912",
      "_fbp": "fb.2.1753314946411.298647545202713527",
      "FPAU": "1.1.1371882672.1753314944",
      "ncx": "m",
      "bm_ss": "ab8e18ef4e",
      "bm_so": "B2A47DA7F90A6320782F07BACE287574C55F4F294407E63866EB138C9CE135D9~YAAQulozuORF162YAQAAucluywTai9bOaKXFkrnVcRAVpMMkCr+XhzXB5rPncM/I9sFSO+8Wjl+hTDkKcRcE2g7VJD2HKWagFXrTcqdqYiDUrdqYnkjwN8J+FgbEM5CTWVMqbYCk+GMqZfuMI3IJ1O5lJkEUXqdpugQLAn/pSPQRhKx6slhBbNnCmzmtDVx8FAp7xuI3YzGzQCR6NKWofYaBeZ1N110evHq8k5qoMLj6qLUA9qrBwQ7PifesL0DBdrAH/4WGCxumfdxqqmSOc4O9D8cI6GQUuoVW6Xq+Y1aRY27ZRkh/R4OERuxGoBK2sUi2UHS4kRVYdre4S3auOhZ5R0HTuPdZnhx8QzRIq61V8H1xXaJzwjhVB8OUYQBl5SqW/i8JgA57WIV3ICb5WxHDFqoFE3rWREv6I58gtn9aOdVKqZsjV4YBWdacMgZ/ksBWbwWdhVxnBhbDesAIybM=",
      "bm_lso": "B2A47DA7F90A6320782F07BACE287574C55F4F294407E63866EB138C9CE135D9~YAAQulozuORF162YAQAAucluywTai9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OZyPLhBv6ybWcU2FOn3wFjx2Bi0RuSgR89Eq2BrrrM54yBhqsr5D59s38ss6CT5su1rS0dEE2y/jzTKwTZK4dmIrnceySmh8Rc4TyqWxWL/iXsLeZ6nQO1NvCkIn8oJzbHHbtC1J7EcFBK76D1CvA9xoSWFwgKPMM5UtDSpC3fCOE/+5sVXaqmJz69kGSedba6ey0Cpl6J7fcKIAiHg1aTWoec2/QTigR/QLrTDXItjdq+zeubjqU4c5e2VqdZL5u9rLjShEYjqW6FpGIwQffn7Mj6pnJy1EP28OskVtoheBD/+P1r1Y12w5VOd0oAik234exVdtfOQgp9lgJPnDBvGe88gGhwkbsX1BOHh6+iMCTL1vBYi9muiSWZJ8QLyzjB73DgvE8ID9WYRcXU2h2lIFl1hu7dWVIlzlnFy1hQKcRYkJ4kvAZid5gtBJBza8oyP6uMilr7JxJCv0Cl9x6GChN4VhlzykT94k6v8vKF7Lg5JJYlaY=~-1~-1~-1",
      "_ga_MDW1S9PQPW": "GS2.1.s1755759707$o12$g0$t1755759710$j57$l0$h760933573"
}
    file_name_page = 1
    for a in  range(1,11):
        res = get(a)



        for indx, a in enumerate(res,1):#循环返回的m并且计数，从1开始，indx从1开始，a就是商品ID
            file_name = str(file_name_page)
            file_name = file_name+"_"+str(indx)
            create_folder(file_name)#创建文件夹1
            b = a.split('::')[-1]#清洗商品ID，去除不需要的字符
            url = f'https://www.zalando.co.uk/outfits/{b}/'#商品详情的url
            cont = get_data(url)#请求商品的详情数据
            etrr = etree.HTML(cont)#解析商品详情页面的数据
            li = etrr.xpath('//ul[@class="XLgdq7 _0xLoFW _78xIQ- _8n7CyI _06gkQU r9BRio xlsKrm _4oK5GO _MmCDa heWLCX KLaowZ"]/li')#查找商品详情页面的模特图，返回列表，[0:1]这个可以选择下载几张模特图，0是从头开始，1是第一张

            file_number_jian = 0
            for indx2,c in enumerate(li,1):#循环列表，从1开始
                if indx2 ==2:
                    # downloadImages(os.path.join(str(indx), str(indx2)+'模特图'), new_modelPicture)   8.11.14:31
                    # downloadVideos(os.path.join(str(file_name),str(indx2)+'模特图'), new_modelPicture)
                    file_number_jian=1
                    continue
                else:
                    modelPicture = c.xpath('./div/button/div/div/img/@src')[0]#拿到模特图的URL
                    modelPicture = modelPicture.split('=')[-2]
                    new_modelPicture = modelPicture+'=1000'
                    #下载模特图，os.path.join(str(indx), str(indx2)+'模特图'拼接图片的下载路径
                    # downloadImages(os.path.join(str(indx), str(index2) + '模特图'),
                    #                new_modelPicture)  # 下载模特图，os.path.join(str(indx), str(indx2)+'模特图'拼接图片的下载路径
                    indx4 = indx2-file_number_jian
                    downloadImages(os.path.join(str(file_name),str(indx4)+'模特图'), new_modelPicture)  # 下载模特图，os.path.join(str(indx), str(indx2)+'模特图'拼接图片的下载路径

                print(f'模特图{indx4}下载完成')



            # #跳转图片页面
            lists = etrr.xpath('//a[@class="LyRfpJ JT3_zV CKDt_l q84f1m E1wRN6 snL7ze"]/@href')
            for indx5,u in enumerate(lists,1):
                htmls = etree.HTML(get_data(u))

                # 保存商品标题
                title = str(((htmls.xpath('//h1[@class="voFjEy SbJZ75 m3OCL3 HlZ_Tf"]//text()'))))
                title=title.replace('[','')
                title = title.replace(']', '')
                title = title.replace(',', '')
                title = title.replace('\'', '')
                # title = title+'\n'+str(htmls.xpath('//span[@class ="EKabf7 R_QwOV"]/text()'))
                color = str((htmls.xpath('//span[@class ="voFjEy _3ObVF2 Sb5G3D HlZ_Tf zN9KaA"]/text()')))
                color=color.replace('[','')
                color = color.replace(']', '')
                color = color.replace(',', '')
                color = color.replace('\'', '')
                title = title+'\n'+'Color: '+color

                #最终
                describe5 = htmls.xpath('//div[@class="Z1Xqqm sb1S7G sKmkSN pMa0tB"]')[0]
                paragraph1 = describe5.xpath('//dt[@class="voFjEy _3ObVF2 Sb5G3D HlZ_Tf zN9KaA"]/text()')
                paragraph2 = describe5.xpath('//dd[@class="voFjEy _3ObVF2 m3OCL3 HlZ_Tf zN9KaA"]/text()')

                # describe_sum1 = "Material & care:"
                describe_sum1=""
                index10=0
                for index9,i in enumerate(paragraph2):
                    describe_sum1+=paragraph1[index10]+paragraph1[index10+1]+' '+paragraph2[index9]+'; '
                    index10=index10+2
                describe_sum1 = describe_sum1.rstrip(';') + '.'

                title=title+'\n'+describe_sum1

                downtextTest(os.path.join(str(file_name), str(indx5) + '商品描述'), title)


                #方案一：
                # describe1 = htmls.xpath('//dd[@class="voFjEy _3ObVF2 m3OCL3 HlZ_Tf zN9KaA"]/text()')

                # downtextTest(os.path.join(str(file_name), str(indx5) + '商品描述'),describe1)
                #清洗describe
                #方案二
                # describe_list = htmls.xpath('//div[@class="Z1Xqqm sb1S7G sKmkSN pMa0tB"]//text()')
                # describe = str(describe_list)
                # describe2 = describe.replace(", 'Item alerts', 'Fashion updates', 'Your brands and creators', 'Recommendations', 'Size Reminder Confirmation', 'Stories', 'Offers and sales', 'Surveys', 'See more (you’ll need to sign in)'",'',1)
                # describe_list=list(describe2)
                # downtextTest(os.path.join(str(file_name), str(indx5) + '商品描述'),describe_list)

                # 方案三：
                # describe3=htmls.xpath('//div[@class="Z1Xqqm sb1S7G sKmkSN pMa0tB"]//dt[@class="voFjEy _3ObVF2 Sb5G3D HlZ_Tf zN9KaA"]/text()')
                # describe4=htmls.xpath('//div[@class="Z1Xqqm sb1S7G sKmkSN pMa0tB"]//dd[@class="voFjEy _3ObVF2 m3OCL3 HlZ_Tf zN9KaA"]/text()')
                # index8=0
                # describe_sum=""
                # for index7 in enumerate(describe4):
                #     describe_sum+=describe3[index8]+describe3[index8+1]+describe4[index7]
                #     index8=index8+2
                #
                # print(describe3)


                #方案四
                # describe5 = htmls.xpath('//div[@class="Z1Xqqm sb1S7G sKmkSN pMa0tB"]')[0]
                # paragraph1 = describe5.xpath('//dt[@class="voFjEy _3ObVF2 Sb5G3D HlZ_Tf zN9KaA"]/text()')
                # paragraph2 = describe5.xpath('//dd[@class="voFjEy _3ObVF2 m3OCL3 HlZ_Tf zN9KaA"]/text()')
                #
                # describe_sum1 = "Material & care:"
                # index10=0
                # for index9,i in enumerate(paragraph2):
                #     describe_sum1+=paragraph1[index10]+paragraph1[index10+1]+paragraph2[index9]+';'
                #     index10=index10+2
                # describe_sum1 = describe_sum1.rstrip(';') + '.'
                #
                # describe6 = htmls.xpath('//div[@class="Z1Xqqm sb1S7G sKmkSN pMa0tB"]')[1]
                # paragraph3 = describe6.xpath('//dt[@class="voFjEy _3ObVF2 Sb5G3D HlZ_Tf zN9KaA"]/text()')
                # paragraph4 = describe6.xpath('//dd[@class="voFjEy _3ObVF2 m3OCL3 HlZ_Tf zN9KaA"]/text()')
                # describe_sum2 = "Details:"
                # index10 = 0
                # for index9,i in enumerate(paragraph4):
                #     describe_sum2+=paragraph3[index10]+paragraph3[index10+1]+paragraph4[index9]+';'
                #     index10 = index10 + 2
                # describe_sum2 = describe_sum2.rstrip(';') + '.'
                #
                # describe7 = htmls.xpath('//div[@class="Z1Xqqm sb1S7G sKmkSN pMa0tB"]')[2]
                # paragraph5 = describe7.xpath('//dt[@class="voFjEy _3ObVF2 Sb5G3D HlZ_Tf zN9KaA"]/text()')
                # paragraph6 = describe7.xpath('//dd[@class="voFjEy _3ObVF2 m3OCL3 HlZ_Tf zN9KaA"]/text()')
                # describe_sum3="Size & fit:"
                # index10 = 0
                # for index9,i in enumerate(paragraph6):
                #     describe_sum3+=paragraph5[index10]+paragraph5[index10+1]+paragraph6[index9]+';'
                #     index10 = index10 + 2
                # describe_sum3 = describe_sum3.rstrip(';') + '.'
                #
                # describe_sum=describe_sum1+describe_sum2+describe_sum3
                #
                # print(describe_sum)









                #进行商品图片多角度保存
                folder_name = os.path.join(file_name,str(indx5)+'商品多角度细节图')
                create_folder(folder_name)
                img_list = htmls.xpath('//img[@class="voFjEy _3ObVF2 m3OCL3 _2Pvyxl JT3_zV EKabf7 mo6ZnF _1RurXL mo6ZnF _7ZONEy"]/@src')
                for index6,img in enumerate(img_list,1):
                    if(index6>6):
                        break
                    productImage=img
                    if (productImage.find('=') != -1):
                        if (checkStr1(productImage, '=') == 2):
                            ImageImwidth = productImage.split('=')[-3]
                            new_ImageImwith = ImageImwidth + '=1000'
                            downloadImages(os.path.join(str(folder_name), str(index6) + '商品细节图'), new_ImageImwith)
                        else:
                            ImageImwidth = productImage.split('=')[-2]
                            new_ImageImwith = ImageImwidth + '=1000'
                            downloadImages(os.path.join(str(folder_name), str(index6) + '商品细节图'), new_ImageImwith)
                    else:
                        downloadImages(os.path.join(str(folder_name), str(index6) + '商品细节图'), productImage)

            #下载图片
            # div = etrr.xpath('//img[@class="voFjEy lystZ1 m3OCL3 _2Pvyxl JT3_zV EKabf7 mo6ZnF _1RurXL mo6ZnF _7ZONEy tCiGa7 ZkIJC-"]/@src')   8.11.15.13

            div = etrr.xpath(
                '//img[@class="voFjEy _3ObVF2 m3OCL3 _2Pvyxl JT3_zV EKabf7 mo6ZnF _1RurXL mo6ZnF _7ZONEy tCiGa7 ZkIJC-"]/@src')
            for indx3,d in enumerate(div,1):
                productImage = d
                if(productImage.find('=')!=-1):
                    if(checkStr1(productImage,'=')==2):
                        ImageImwidth = productImage.split('=')[-3]
                        # ImageImwidth2 = ImageImwidth.split('&')[-2]
                        new_ImageImwith = ImageImwidth+'=1000'
                        # new_ImageImwith = ImageImwidth+'&filter=packshot'
                        downloadImages(os.path.join(str(file_name), str(indx3)+'商品图'), new_ImageImwith)
                        # downloadVideos(os.path.join(str(file_name), str(indx3) + '商品图'), new_ImageImwith)
                    else:
                        ImageImwidth = productImage.split('=')[-2]
                        # ImageImwidth2 = ImageImwidth.split('&')[-2]
                        new_ImageImwith = ImageImwidth+'=1000'
                        # new_ImageImwith = ImageImwidth+'&filter=packshot'
                        # downloadImages(os.path.join(str(indx), str(indx3)+'商品图'), new_ImageImwith)
                        downloadImages(os.path.join(str(file_name), str(indx3) + '商品图'), new_ImageImwith)
                else:
                    # downloadImages(os.path.join(str(indx), str(indx3) + '商品图'), productImage)
                    downloadImages(os.path.join(str(file_name), str(indx3) + '商品图'), productImage)
                # 下载文字
                # downtextTest(os.path.join(str(file_name), str(indx3) + '商品描述'))

                print(f'商品图{indx3}下载完成')




        file_name_page=file_name_page+1